package com.ncu.gulimall.order.vo;

import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

//@Data
public class OrderConfirmVo {

    //防重令牌
    @Getter
    @Setter
    private String orderToken;

    //用户收货地址列表 - ums_member_receive_address
    @Getter
    @Setter
    private List<MemberAddressVo> address;

    //所有选中的购物项
    @Getter
    @Setter
    private List<OrderItemVo> items;

    //发票记录信息

    //优惠券信息
    @Getter
    @Setter
    private Integer integration;

    @Setter
    @Getter
    private Map<Long, Boolean> stocks;

    public Integer getCount() {
        Integer i = 0;
        if (this.items != null) {
            for (OrderItemVo item : this.items) {
                i += item.getCount();
            }
        }
        return i;
    }

    //订单总额
    public BigDecimal getTotal() {
        BigDecimal total = new BigDecimal("0");
        if (this.items != null) {
            for (OrderItemVo item : this.items) {
                BigDecimal decimal = item.getPrice().multiply(new BigDecimal(item.getCount()));
                total = total.add(decimal);
            }
        }
        return total;
    }

    //应付价格
    public BigDecimal getPayPrice() {
        return getTotal();
    }
}
